﻿#if WINDOWS_PHONE
#else
using Microsoft.Xna.Framework.Net;

namespace JGLib.Net
{
    public abstract class CreateSessionState : JGLib.States.State
    {
        protected NetworkSession NetSession { get; set; }

        protected NetUtil.GamerJoinedEvent GamerJoined;
        protected NetUtil.GamerLeftEvent GamerLeft;
        protected NetUtil.SessionJoinedEvent SessionJoined;

        public CreateSessionState(object ID, NetUtil.GamerJoinedEvent gamerJoined, NetUtil.GamerLeftEvent gamerLeft, NetUtil.SessionJoinedEvent sessionJoined)
            : base(ID)
        {
            this.GamerJoined = gamerJoined;
            this.GamerLeft = gamerLeft;
            this.SessionJoined = sessionJoined;
        }

        protected void CreateSession(int numPlayers)
        {
            this.NetSession = NetworkSession.Create(NetworkSessionType.SystemLink, 1, numPlayers);
            this.NetSession.AllowHostMigration = true;
            this.NetSession.AllowJoinInProgress = false;

            this.NetSession.InitSession(this.GamerJoined, this.GamerLeft, this.SessionJoined);
        }
    }
}
#endif